

/*---------------------------------------------------------
   Name: Initialize
---------------------------------------------------------*/
function ENT:Initialize()	
	
	self.StartTime = CurTime()
	
	self:SetCollisionBounds( Vector( -300, -300, -300 ), Vector( 300, 300, 0 ) )
	
	self:SetMoveType( MOVETYPE_NONE )
	self:SetSolid( SOLID_NONE )
	
end


local FADETIME = 0.5

/*---------------------------------------------------------
   Name: DrawPre
---------------------------------------------------------*/
function ENT:Draw()

	if (self.Gas == nil) then return end
	
	for k, v in pairs(self.Gas) do
		self:DrawGas( v, Mul )
	end

end


function ENT:DrawGas( tab, mul )

	self.Delay = self.Delay or 1
	
	if self.Delay == 6 then
	
		self.Delay = 0
		
		local Velocity = Vector(math.Rand(-1,1),math.Rand(-1,1),0)
		local rvec = (VectorRand() * math.random(1,10)) + Vector(math.Rand(-20,20),math.Rand(-20,20),0)
		local pos = tab.Pos + Vector(math.random(-10,10),math.random(-10,10))
		
		local emitter = ParticleEmitter( pos )
		
		local particle = emitter:Add( "particle/particle_smokegrenade", pos )
			particle:SetVelocity( (Velocity * math.Rand( 80, 110 )) + WindVector )
			particle:SetDieTime( tab.DieTime )
			particle:SetStartAlpha( math.Rand( 20, 30 ) )
			particle:SetEndAlpha( 1 )
			particle:SetStartSize( tab.Size )
			particle:SetEndSize( math.Rand( 50, 70 ) )
			particle:SetRoll( math.Rand( 0, 360 ) )
			particle:SetRollDelta( math.Rand( -0.1, 0.1 ) )
			particle:SetColor( math.Rand( 100, 170 ), math.Rand( 100, 150 ), 50 )
			particle:VelocityDecay( false )
			
		emitter:Finish()
	else
		self.Delay = self.Delay + 1
	end
end


function ENT:Think()

	if (self.Gas != nil) then return end

	self.Gas = {}
	
	local gas = {}
		gas.Pos = self:GetPos() //- Vector(0,0,30)
		gas.Size = math.Rand( 40, 50 )
		gas.DieTime = math.Rand( 4, 5 )

	table.insert( self.Gas, gas )
	
	for i=0,math.random(2,3) do
	
		local gas = {}
			gas.Pos = (self:GetPos() + Vector(math.random(-20,20),math.random(-20,20),0) )
			gas.Size = math.Rand( 70, 90 )
			gas.DieTime = math.Rand( 3, 5 )
			
		table.insert( self.Gas, gas )
	end
end


include('shared.lua')